package gui.entity;

import generated.domain.user.User;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;

public class UserElementPropertySource implements IPropertySource {

	private static final String PROPERTY_ID_NAME = "user.name";
	private static final Object PROPERTY_ID_EMAIL = "user.email";
	private static final Object PROPERTY_ID_LOGIN = "user.login";
	private static final Object PROPERTY_ID_PASSWORD = "user.password";
	private final User user;

	private IPropertyDescriptor[] propertyDescriptors;

	public UserElementPropertySource(UserEntity element) {
		user = element.getUser();
	}

	public IPropertyDescriptor[] getPropertyDescriptors() {
		if (propertyDescriptors == null) {
			PropertyDescriptor nameDescriptor = new PropertyDescriptor(
					PROPERTY_ID_NAME, "Name");

			PropertyDescriptor moodDescriptor = new PropertyDescriptor(
					PROPERTY_ID_EMAIL, "Email");

			PropertyDescriptor genderDescriptor = new PropertyDescriptor(
					PROPERTY_ID_LOGIN, "Login");

			PropertyDescriptor sizeDescriptor = new PropertyDescriptor(
					PROPERTY_ID_PASSWORD, "Password");

			propertyDescriptors = new IPropertyDescriptor[] { nameDescriptor,
					moodDescriptor, genderDescriptor, sizeDescriptor };
		}
		return propertyDescriptors;
	}

	public Object getEditableValue() {
		// TODO Auto-generated method stub
		return null;
	}

	public Object getPropertyValue(Object id) {
		if (id.equals(PROPERTY_ID_NAME))
			return user.name;
		if (id.equals(PROPERTY_ID_EMAIL))
			return user.email;
		if (id.equals(PROPERTY_ID_LOGIN))
			return user.login;
		if (id.equals(PROPERTY_ID_PASSWORD))
			return user.password;
		return "";
	}

	public boolean isPropertySet(Object id) {
		// TODO Auto-generated method stub
		return false;
	}

	public void resetPropertyValue(Object id) {
		// TODO Auto-generated method stub

	}

	public void setPropertyValue(Object id, Object value) {
		// TODO Auto-generated method stub

	}
}